From 9773f5386e655c7c6fb42fffc1b948d8c1595342 Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Tue, 15 Nov 2005 18:47:39 +0100 Subject: [PATCH] Remove the handling of TypeError inside gather. It is not thrown by int() when given a non-convertible value, as claimed by the comment, as the exception ValueError is thrown in that situation. TypeError is only thrown on int(None), which cannot actually take place in this code, because of the explicit check for None. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/xenstore/xstransact.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/python/xen/xend/xenstore/xstransact.py b/tools/python/xen/xend/xenstore/xstransact.py index ac06c2b1b8..dcdad54a22 100644 --- a/tools/python/xen/xend/xenstore/xstransact.py +++ b/tools/python/xen/xend/xenstore/xstransact.py @@ -177,18 +177,15 @@ class xstransact: (key, fn, defval) = tup val = self._read(key) - # If fn is str, then this will successfully convert None to - # 'None'. If it is int, then it will throw TypeError on None, or - # on any other non-integer value. We have to, therefore, both - # check explicitly for None, and catch TypeError. Either failure - # will result in defval being used instead. + # If fn is str, then this will successfully convert None to 'None' + # (which we don't want). If it is int or float, then it will + # throw ValueError on any non-convertible value. We check + # explicitly for None, using defval instead, but allow ValueError + # to propagate. if val is None: val = defval else: - try: - val = fn(val) - except TypeError: - val = defval + val = fn(val) ret.append(val) if len(ret) == 1: return ret[0] -- 2.30.2